namespace = cr_orthodox

########################################
# Coronation state controller
########################################

character_event = {
	id = cr_orthodox.1
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				religion = orthodox
				is_landed = yes
				higher_tier_than = DUKE
				NOT = { controls_religion = yes }
			}
			if = {
				limit = { has_character_flag = cr_orthodox_crowned }
				remove_character_modifier = cr_orthodox_uncrowned
				if = {
					limit = { NOT = { has_character_modifier = cr_orthodox_consecrated } }
					add_character_modifier = { name = cr_orthodox_consecrated duration = -1 }
				}
			}
			else_if = {
				limit = { NOT = { has_character_modifier = cr_orthodox_uncrowned } }
				add_character_modifier = { name = cr_orthodox_uncrowned duration = -1 }
			}
		}
		else = {
			remove_character_modifier = cr_orthodox_uncrowned
			remove_character_modifier = cr_orthodox_consecrated
			clr_character_flag = cr_orthodox_crowned
			clr_character_flag = cr_orthodox_coronation_pending
			clear_persistent_event_target = cr_orthodox_coronator
		}
	}
}

########################################
# Coronation request and ceremony
########################################

long_character_event = {
	id = cr_orthodox.10
	title = CR_ORTHODOX_10_TITLE
	desc = CR_ORTHODOX_10_DESC
	picture = GFX_cr_evt_religious_exultation
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	option = {
		name = CR_ORTHODOX_10_A
		set_character_flag = cr_orthodox_coronation_pending
		save_event_target_as = cr_orthodox_coronation_ruler
		save_persistent_event_target = {
			name = cr_orthodox_coronator
			scope = rightful_religious_head_scope
		}
		rightful_religious_head_scope = {
			long_character_event = { id = cr_orthodox.11 }
		}
	}
	option = { name = CR_ORTHODOX_10_B }
}

long_character_event = {
	id = cr_orthodox.11
	title = CR_ORTHODOX_11_TITLE
	desc = CR_ORTHODOX_11_DESC
	picture = GFX_cr_evt_council_speaker
	border = GFX_event_long_frame_religion
	is_triggered_only = yes
	trigger = {
		event_target:cr_orthodox_coronation_ruler = {
			is_alive = yes
			has_character_flag = cr_orthodox_coronation_pending
		}
	}

	option = {
		name = CR_ORTHODOX_11_A
		ai_chance = {
			factor = 45
			modifier = { factor = 1.5 trait = kind }
			modifier = { factor = 1.5 trait = charitable }
		}
		event_target:cr_orthodox_coronation_ruler = { long_character_event = { id = cr_orthodox.12 } }
	}
	option = {
		name = CR_ORTHODOX_11_B
		ai_chance = { factor = 25 modifier = { factor = 2 trait = greedy } }
		event_target:cr_orthodox_coronation_ruler = { long_character_event = { id = cr_orthodox.13 } }
	}
	option = {
		name = CR_ORTHODOX_11_C
		ai_chance = { factor = 20 modifier = { factor = 2 trait = zealous } }
		event_target:cr_orthodox_coronation_ruler = { long_character_event = { id = cr_orthodox.14 } }
	}
	option = {
		name = CR_ORTHODOX_11_D
		ai_chance = { factor = 10 modifier = { factor = 2 trait = proud } }
		event_target:cr_orthodox_coronation_ruler = { long_character_event = { id = cr_orthodox.15 } }
	}
}

long_character_event = {
	id = cr_orthodox.12
	title = CR_ORTHODOX_12_TITLE
	desc = CR_ORTHODOX_12_DESC
	picture = GFX_cr_evt_religious_exultation
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	option = {
		name = CR_ORTHODOX_12_A
		long_character_event = { id = cr_orthodox.20 days = 7 }
	}
}

long_character_event = {
	id = cr_orthodox.13
	title = CR_ORTHODOX_13_TITLE
	desc = CR_ORTHODOX_13_DESC
	picture = GFX_cr_evt_council_speaker
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	option = {
		name = CR_ORTHODOX_13_A
		cr_orthodox_coronation_donation_effect = yes
		set_character_flag = cr_orthodox_coronation_donation
		long_character_event = { id = cr_orthodox.20 days = 7 }
	}
	option = {
		name = CR_ORTHODOX_13_B
		clr_character_flag = cr_orthodox_coronation_pending
		clear_persistent_event_target = cr_orthodox_coronator
	}
}

long_character_event = {
	id = cr_orthodox.14
	title = CR_ORTHODOX_14_TITLE
	desc = CR_ORTHODOX_14_DESC
	picture = GFX_cr_evt_religious_exultation
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	option = {
		name = CR_ORTHODOX_14_A
		set_character_flag = cr_orthodox_coronation_penance
		piety = -250
		prestige = -250
		if = { limit = { trait = proud } remove_trait = proud }
		long_character_event = { id = cr_orthodox.20 days = 7 }
	}
	option = {
		name = CR_ORTHODOX_14_B
		clr_character_flag = cr_orthodox_coronation_pending
		clear_persistent_event_target = cr_orthodox_coronator
	}
}

long_character_event = {
	id = cr_orthodox.15
	title = CR_ORTHODOX_15_TITLE
	desc = CR_ORTHODOX_15_DESC
	picture = GFX_cr_evt_bad_news
	border = GFX_event_long_frame_religion
	is_triggered_only = yes
	immediate = {
		clr_character_flag = cr_orthodox_coronation_pending
		clear_persistent_event_target = cr_orthodox_coronator
		if = {
			limit = { rightful_religious_head_scope = { is_alive = yes } }
			rightful_religious_head_scope = {
				opinion = { modifier = cr_orthodox_coronation_refused who = ROOT years = 5 }
			}
		}
	}
	option = { name = CR_ORTHODOX_15_A }
}

long_character_event = {
	id = cr_orthodox.20
	title = CR_ORTHODOX_20_TITLE
	desc = CR_ORTHODOX_20_DESC
	picture = GFX_cr_evt_religious_exultation
	border = GFX_event_long_frame_religion
	is_triggered_only = yes
	immediate = {
		cr_pilgrimage_find_companion_effect = yes
		cr_orthodox_find_rite_participants_effect = yes
	}

	option = {
		name = CR_ORTHODOX_20_A
		piety = 75
		cr_orthodox_clear_rite_participants_effect = yes
		long_character_event = { id = cr_orthodox.21 days = 3 }
		ai_chance = { factor = 40 modifier = { factor = 1.5 learning = 14 } }
	}
	option = {
		name = CR_ORTHODOX_20_B
		prestige = 75
		cr_orthodox_clear_rite_participants_effect = yes
		long_character_event = { id = cr_orthodox.21 days = 3 }
		ai_chance = { factor = 35 modifier = { factor = 1.5 diplomacy = 14 } }
	}
	option = {
		name = CR_ORTHODOX_20_C
		trigger = { event_target:cr_pilgrimage_companion = { cr_valid_intimacy_partner_trigger = yes } }
		event_target:cr_pilgrimage_companion = { save_event_target_as = cr_intimacy_partner }
		cr_resolve_contextual_intimacy_effect = yes
		clear_event_target = cr_intimacy_partner
		cr_gain_carnal_good_ending_trait_effect = yes
		cr_orthodox_clear_rite_participants_effect = yes
		long_character_event = { id = cr_orthodox.21 days = 3 }
		ai_chance = { factor = 25 modifier = { factor = 2 trait = lustful } modifier = { factor = 0.5 trait = chaste } }
	}
	option = {
		name = CR_ORTHODOX_20_D
		trigger = {
			event_target:cr_orthodox_rite_partner_1 = { cr_valid_intimacy_partner_trigger = yes }
			event_target:cr_orthodox_rite_partner_2 = { cr_valid_intimacy_partner_trigger = yes }
		}
		cr_orthodox_resolve_group_rite_effect = yes
		long_character_event = { id = cr_orthodox.21 days = 3 }
		ai_chance = { factor = 20 modifier = { factor = 3 trait = lustful } modifier = { factor = 2 trait = exhibitionist } modifier = { factor = 0.25 trait = chaste } }
	}
}

long_character_event = {
	id = cr_orthodox.21
	title = CR_ORTHODOX_21_TITLE
	desc = CR_ORTHODOX_21_DESC
	picture = GFX_cr_evt_feast
	border = GFX_event_long_frame_religion
	is_triggered_only = yes

	option = {
		name = CR_ORTHODOX_21_A
		cr_orthodox_complete_coronation_effect = yes
	}
}

########################################
# Sacred iconography
########################################

long_character_event = {
	id = cr_orthodox.30
	title = CR_ORTHODOX_30_TITLE
	desc = CR_ORTHODOX_30_DESC
	picture = GFX_cr_evt_religious_exultation
	border = GFX_event_long_frame_religion
	is_triggered_only = yes
	immediate = {
		cr_pilgrimage_find_companion_effect = yes
		cr_orthodox_find_rite_participants_effect = yes
	}

	option = {
		name = CR_ORTHODOX_30_A
		wealth = -50
		capital_scope = { add_province_modifier = { name = cr_orthodox_living_iconography duration = 3650 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		piety = 100
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_30_B
		trigger = { wealth = 100 }
		wealth = -100
		capital_scope = { add_province_modifier = { name = cr_orthodox_living_iconography duration = 7300 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		prestige = 100
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_30_C
		trigger = { event_target:cr_pilgrimage_companion = { cr_valid_intimacy_partner_trigger = yes } }
		wealth = -50
		capital_scope = { add_province_modifier = { name = cr_orthodox_living_iconography duration = 3650 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		piety = 50
		prestige = 50
		event_target:cr_pilgrimage_companion = { save_event_target_as = cr_intimacy_partner }
		cr_resolve_contextual_intimacy_effect = yes
		clear_event_target = cr_intimacy_partner
		cr_gain_carnal_good_ending_trait_effect = yes
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_30_D
		trigger = {
			event_target:cr_orthodox_rite_partner_1 = { cr_valid_intimacy_partner_trigger = yes }
			event_target:cr_orthodox_rite_partner_2 = { cr_valid_intimacy_partner_trigger = yes }
		}
		wealth = -50
		capital_scope = { add_province_modifier = { name = cr_orthodox_living_iconography duration = 3650 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		cr_orthodox_resolve_group_rite_effect = yes
	}
}

long_character_event = {
	id = cr_orthodox.31
	title = CR_ORTHODOX_31_TITLE
	desc = CR_ORTHODOX_31_DESC
	picture = GFX_cr_evt_religious_exultation
	border = GFX_event_long_frame_religion
	is_triggered_only = yes
	immediate = {
		cr_pilgrimage_find_companion_effect = yes
		cr_orthodox_find_rite_participants_effect = yes
	}

	option = {
		name = CR_ORTHODOX_31_A
		wealth = -50
		capital_scope = { add_province_modifier = { name = cr_iconoclast_measured_iconography duration = 3650 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		piety = 100
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_31_B
		trigger = { wealth = 75 }
		wealth = -75
		capital_scope = { add_province_modifier = { name = cr_iconoclast_measured_iconography duration = 5475 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		prestige = 75
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_31_C
		trigger = { event_target:cr_pilgrimage_companion = { cr_valid_intimacy_partner_trigger = yes } }
		wealth = -50
		capital_scope = { add_province_modifier = { name = cr_iconoclast_measured_iconography duration = 3650 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		piety = 50
		prestige = 50
		event_target:cr_pilgrimage_companion = { save_event_target_as = cr_intimacy_partner }
		cr_resolve_contextual_intimacy_effect = yes
		clear_event_target = cr_intimacy_partner
		cr_gain_carnal_good_ending_trait_effect = yes
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_31_D
		trigger = {
			event_target:cr_orthodox_rite_partner_1 = { cr_valid_intimacy_partner_trigger = yes }
			event_target:cr_orthodox_rite_partner_2 = { cr_valid_intimacy_partner_trigger = yes }
		}
		wealth = -50
		capital_scope = { add_province_modifier = { name = cr_iconoclast_measured_iconography duration = 3650 } }
		add_character_modifier = { name = cr_orthodox_marian_teacher duration = 3650 }
		cr_orthodox_resolve_group_rite_effect = yes
	}
}

########################################
# Doctrinal identity
########################################

long_character_event = {
	id = cr_orthodox.40
	title = CR_ORTHODOX_40_TITLE
	desc = CR_ORTHODOX_40_DESC
	picture = GFX_cr_evt_library
	border = GFX_event_long_frame_religion
	is_triggered_only = yes
	trigger = {
		religion = orthodox
		is_adult = yes
		is_ruler = yes
		NOT = { has_character_flag = cr_orthodox_marian_doctrine_seen }
	}
	immediate = {
		set_character_flag = cr_orthodox_marian_doctrine_seen
		cr_pilgrimage_find_companion_effect = yes
		cr_orthodox_find_rite_participants_effect = yes
	}

	option = { name = CR_ORTHODOX_40_A learning = 1 piety = 100 cr_orthodox_clear_rite_participants_effect = yes }
	option = { name = CR_ORTHODOX_40_B diplomacy = 1 prestige = 75 cr_orthodox_clear_rite_participants_effect = yes }
	option = {
		name = CR_ORTHODOX_40_C
		trigger = { event_target:cr_pilgrimage_companion = { cr_valid_intimacy_partner_trigger = yes } }
		event_target:cr_pilgrimage_companion = { save_event_target_as = cr_intimacy_partner }
		cr_resolve_contextual_intimacy_effect = yes
		clear_event_target = cr_intimacy_partner
		piety = 50
		prestige = 50
		cr_gain_carnal_good_ending_trait_effect = yes
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_40_D
		trigger = {
			event_target:cr_orthodox_rite_partner_1 = { cr_valid_intimacy_partner_trigger = yes }
			event_target:cr_orthodox_rite_partner_2 = { cr_valid_intimacy_partner_trigger = yes }
		}
		cr_orthodox_resolve_group_rite_effect = yes
	}
}

long_character_event = {
	id = cr_orthodox.41
	title = CR_ORTHODOX_41_TITLE
	desc = CR_ORTHODOX_41_DESC
	picture = GFX_cr_evt_council
	border = GFX_event_long_frame_religion
	is_triggered_only = yes
	trigger = {
		religion = iconoclast
		is_adult = yes
		is_ruler = yes
		NOT = { has_character_flag = cr_iconoclast_image_doctrine_seen }
	}
	immediate = {
		set_character_flag = cr_iconoclast_image_doctrine_seen
		cr_pilgrimage_find_companion_effect = yes
		cr_orthodox_find_rite_participants_effect = yes
	}

	option = { name = CR_ORTHODOX_41_A stewardship = 1 piety = 100 cr_orthodox_clear_rite_participants_effect = yes }
	option = { name = CR_ORTHODOX_41_B learning = 1 prestige = 75 cr_orthodox_clear_rite_participants_effect = yes }
	option = {
		name = CR_ORTHODOX_41_C
		trigger = { event_target:cr_pilgrimage_companion = { cr_valid_intimacy_partner_trigger = yes } }
		event_target:cr_pilgrimage_companion = { save_event_target_as = cr_intimacy_partner }
		cr_resolve_contextual_intimacy_effect = yes
		clear_event_target = cr_intimacy_partner
		piety = 50
		prestige = 50
		cr_gain_carnal_good_ending_trait_effect = yes
		cr_orthodox_clear_rite_participants_effect = yes
	}
	option = {
		name = CR_ORTHODOX_41_D
		trigger = {
			event_target:cr_orthodox_rite_partner_1 = { cr_valid_intimacy_partner_trigger = yes }
			event_target:cr_orthodox_rite_partner_2 = { cr_valid_intimacy_partner_trigger = yes }
		}
		cr_orthodox_resolve_group_rite_effect = yes
	}
}
